<?php $this->renderPartial('//common/header'); ?>
<!-- CONTENT CONTAINER -->
<div id="map"></div>
<div class="container">
	<ul class="breadcrumb">
		<li><a href="<?php echo PIUrl::createUrl('/home/');?>">Trang chủ</a></li>
		<li><span>Liên hệ</span></li>
	</ul>
	<div class="loading" style="display:none">
			<img src="<?php echo Yii::app()->theme->baseUrl;?>/img/front/loading.GIF" alt="img" width="40" height="40">
			<span> Đang gửi...</span>
	</div>
	<div class="content-container row">
		<!-- SIDEBAR -->
			
		<div class="col-md-4 sidebar">
			<div class="info-contact">
				<p class="title-lg"><?php echo $this->arrSystem['title']; ?></p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-address"></i></span>
					<?php echo $this->arrSystem['address']; ?>
				</p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-telephone"></i></span>
					<?php echo $this->arrSystem['phone']; ?>
				</p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-mail-black"></i></span>
					<a href="#"><?php echo $this->arrSystem['email']; ?></a>
				</p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-telephone"></i></span>
					<?php echo $this->arrSystem['fax']; ?>
				</p>
				<p class="title-lg title-md">Nhân viên văn thư</p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-telephone"></i></span>
					<?php echo $this->arrSystem['document_staff']; ?>
				</p>
				<p class="title-lg title-md">Chuyên viên</p>
				<p>
					<span class="wrap-icon text-center"><i class="icon icon-telephone"></i></span>
					<?php echo $this->arrSystem['official']; ?>
					<br />
					<span style="padding-left:0" class="pl">
						<span class="wrap-icon  text-center"><i class="icon icon-telephone"></i></span>
						<?php echo $this->arrSystem['official1']; ?>
					</span>
				</p>
			</div>
		</div>
		<!-- MAIN CONTENT -->
		<div class="col-md-8 main-content">
			<div class="contact-page">
				<div class="popup">
					<h2 class="title title-bd text-center"><span>Liên hệ</span></h2>
					<form method="post" id="formComment1">
						<div class="wrap-form-group">
							<input type="text" class="form-control" name="name" placeholder="Tên">
							<input type="text" class="form-control" name="email" placeholder="Email">
							<input type="text" class="form-control" name="title" placeholder="Tiêu đề">
							<input type="text" class="form-control" name="phone" placeholder="Điện thoại">
							<textarea class="form-control" name="content" cols="30" rows="10" placeholder="Nội dung"></textarea>
						</div>
						<p class="text-center">
							<button type="submit" name="submit" class="btn-custom">Gửi</button>
						</p>
					</form>
				</div>
			</div>
		</div>
	</div>
	<div id="push"> </div>
</div>
</div>
<style>
#formComment1 .error::-webkit-input-placeholder{color:red;}
</style>
<script>
function ValidateEmail(mail)   
{  
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))  
  {  
    return true;  
  }  else return false;
}  

$(document).ready(function(){

	// MAP
    $("#map").gmap3({
        marker: {
            address: "<?php echo $this->arrSystem['address']; ?>",
            options: {
                icon: "<?php echo Yii::app()->theme->baseUrl;?>/img/front/marker.png"
            }
        },
        map: {
            options: {
                zoom: 16,
                scrollwheel: false,
                draggable: true
            }
        }
    });
	
	$("#formComment1").submit(function(){
		var error =  true; errorEmail = true;  var i=0;
		$("#formComment1 .form-control").each(function(){
			i++;
			if(i == 2){
				if(ValidateEmail($(this).val()) == false){ errorEmail = false;
					$(this).attr("class", "error form-control");
					$(this).css("color", "red");
				}else{
					$(this).css("color", "#000");
				}
			}else{
				if($(this).val() == ""){ error = false;
					$(this).attr("class", "error form-control");
				}
			}
			
		});
		if(error == false){
			alert("Bạn cần nhập đầy đủ thông tin"); return false;
		}else{
			if(errorEmail == false){
				$("#formComment1 input[name=email]").focus();
				alert("Email không hợp lệ");
				return false;
			}
		}
		// Form hop le thuc hien send mail
		$(".loading").css("display", "block");
		var data = $('form').serialize();
		$.ajax({url: webroot +"/home/contact/",data:data,type:'post',success:function(data){
			$().toastmessage('showToast', {
				text     : data.msg,
				sticky   : false,
				position : 'top-right',
				type     : 'success',
				close    : function () {console.log("toast is closed ...");}
			});
			$("#formComment1")[0].reset();
			$(".loading").css("display", "none");
		}});
		return false;
	});	
})
</script>
<?php $this->renderPartial('//common/footer'); ?>